<?php
/**
 * Created by PhpStorm.
 * User: moquan
 * Date: 2018/6/20
 * Time: 18:18
 */

namespace app\admin\validate;


class MenuVali extends BaseValidate {

    //定义验证规则
    protected $rule = [
        "menu_name" => "require|min:2|max:12",
        "parent_id" => "require|number",
        "menu_type" => "require",
        "url_value" => "require",
        "roles" => "require",
    ];

    //定义验证提示
    protected $message = [
        "menu_name.require" => "菜单名称不能为空",
        "menu_name.unique" => "菜单名称已存在",
        "menu_name.min" => "菜单名称不能小于5位",
        "menu_name.max" => "菜单名称不能大于22位",
        "menu_type.require" => "菜单类型不能为空",
        "url_value.require" => "菜单链接不能为空",
        "parent_id.require" => "所属菜单不能为空",
        "parent_id.number" => "所属菜单为数字类型",
        "roles.require" => "可见角色不能为空"
    ];

    //定义验证场景
    protected $scene = [
        //添加
        'add'  =>  [],
        // 修改
        'edit'  =>  [],
        // 其它
        'other'  =>  ['id' => 'require|isMustInteger', 'pid'=> 'require|isMustInteger']
    ];

    // 自定义验证规则
    /*protected function checkName($value,$rule,$data)
    {
        return '名称错误';
    }*/
}